#import "AppDelegate.h"
#import "IQKeyboardManager.h"
#import "LoginUtils.h"
#import "MainViewController.h"
#import "LoginViewController.h"
#import "BaseNavigateionViewController.h"
#import "CYLTabBarController.h"

@interface AppDelegate (objc)
@end

@implementation AppDelegate (objc)

#pragma mark 自动处理键盘弹出
-(void)configIQKeyBoard{
    IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
    manager.enable = YES;
    manager.keyboardDistanceFromTextField = 20;
    manager.enableAutoToolbar = NO;
    manager.shouldResignOnTouchOutside = YES;
}

#pragma mark 判断进入登录还是广告页
- (void)judgeLoginOrTab {
    [self setupGuideVC];
}


#pragma mark 已登录，初始化首页
- (void)configTab {
    [self.window setRootViewController:[MainViewController create]];
    [self.window makeKeyAndVisible];
}


#pragma mark 广告引导页
-(void)setupGuideVC {
//    [self createRootNavWithVC:[[GuideViewController alloc] init]];
    [self createRootNavWithVC:[GuideViewController viewController]];
}

#pragma mark 未登录 初始化到登录界面
-(void)setupLoginVC {
    [self createRootNavWithVC:[[LoginViewController alloc] init]];
}


#pragma mark 切换根控制器
-(void)createRootNavWithVC:(id)vc {
    BaseNavigateionViewController *nav = [[BaseNavigateionViewController alloc]initWithRootViewController:vc];
    [nav configCustomNavigationBar];
    [self.window setRootViewController:nav];
    [self.window makeKeyAndVisible];
}

@end
